//划分字母区间
class Solution {
public:
    vector<int> partitionLabels(string s) {
        int alpha[26] = {0};
        //找到字符串s中每个种类的字符最后一次出现的位置
        for(int i = 0;i < s.length();++i)
        {
          alpha[s[i]-'a'] = i;
        }
        int start = 0;
        int end = 0;
        vector<int> ans{};
        for(int i = 0;i < s.length();++i)
        {
          end = std::max(end,alpha[s[i]-'a']);
          if(end == i)
          {
            ans.push_back(end - start + 1);
            start = end + 1;
          }
        }
        return ans;
    }
};